package com.itboye.textileexpres.myset;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.itboye.textileexpres.R;
import com.itboye.textileexpres.base.BaseTextActivity;
import com.itboye.textileexpres.base.SpPublicParams;
import com.itboye.textileexpres.util.SPUtils;

public class ActivityTextSize extends Activity implements OnClickListener {
	TextView small, middle, big;
	ImageView back;

	public int initView() {
		// TODO Auto-generated method stub
		return R.layout.activity_textsize;
	}

	@SuppressWarnings("deprecation")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(initView());
		small = (TextView) findViewById(R.id.small);
		middle = (TextView) findViewById(R.id.middle);
		big = (TextView) findViewById(R.id.big);
		back = (ImageView) findViewById(R.id.back);
		if ("1".equals(SPUtils.get(ActivityTextSize.this, null,
				SpPublicParams.TextSize, "2"))) {
			small.setBackgroundColor(getResources().getColor(R.color.green));
			middle.setBackgroundColor(getResources().getColor(R.color.white));
			big.setBackgroundColor(getResources().getColor(R.color.white));

		} else if ("3".equals(SPUtils.get(ActivityTextSize.this, null,
				SpPublicParams.TextSize, "2"))) {
			small.setBackgroundColor(getResources().getColor(R.color.white));
			middle.setBackgroundColor(getResources().getColor(R.color.white));
			big.setBackgroundColor(getResources().getColor(R.color.green));

		} else {
			small.setBackgroundColor(getResources().getColor(R.color.white));
			middle.setBackgroundColor(getResources().getColor(R.color.green));
			big.setBackgroundColor(getResources().getColor(R.color.white));
		}
		back.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});
		small.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				SPUtils.put(ActivityTextSize.this, null,
						SpPublicParams.TextSize, "1");
				final Intent intent = getPackageManager()
						.getLaunchIntentForPackage(getPackageName());
				intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				startActivity(intent);
			}
		});
		middle.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				SPUtils.put(ActivityTextSize.this, null,
						SpPublicParams.TextSize, "2");
				final Intent intent = getPackageManager()
						.getLaunchIntentForPackage(getPackageName());
				intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				startActivity(intent);
			}
		});
		big.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				SPUtils.put(ActivityTextSize.this, null,
						SpPublicParams.TextSize, "3");
				final Intent intent = getPackageManager()
						.getLaunchIntentForPackage(getPackageName());
				intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				startActivity(intent);
			}
		});

	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		// Intent intent = new Intent("changetextsize");
		// switch (v.getId()) {
		// case R.id.small:
		// intent.putExtra("textsize", 1);
		// Toast.makeText(ActivityTextSize.this, "1", 1).show();
		// sendBroadcast(intent);
		// break;
		// case R.id.middle:
		// intent.putExtra("textsize", 2);
		// Toast.makeText(ActivityTextSize.this, "2", 1).show();
		// sendBroadcast(intent);
		// break;
		// case R.id.big:
		// intent.putExtra("textsize", 3);
		// Toast.makeText(ActivityTextSize.this, "3", 1).show();
		// sendBroadcast(intent);
		// break;
		// default:
		// break;
		// }

	}
}